package com.peng.test.roaringbitmap;

import org.junit.jupiter.api.Test;
import org.roaringbitmap.RoaringBitmap;
import org.roaringbitmap.longlong.LongBitmapDataProvider;
import org.roaringbitmap.longlong.Roaring64NavigableMap;

import java.lang.management.ManagementFactory;
import java.lang.management.RuntimeMXBean;

/**
 * RoaringBitmapSample1
 *
 * @author: lupeng6
 * @create: 2023/3/23 10:27
 */
public class RoaringBitmapSample1 {

    @Test
    public void s1() {
        RoaringBitmap r = RoaringBitmap.bitmapOf(1);
        r.add();
        for (int i = 0; i < 33554432; i++) {
            r.add(i);
        }
        RoaringBitmap r1 = RoaringBitmap.bitmapOf(2);
        // RoaringBitmap r2 = RoaringBitmap.and(r, r1);
        RoaringBitmap r2 = RoaringBitmap.or(r, r1);
        System.out.println(r2.contains(1));
        System.out.println(r2.contains(2));
    }

    @Test
    public void s2() throws InterruptedException {
        LongBitmapDataProvider r = Roaring64NavigableMap.bitmapOf();
        for (long i = 0; i < Integer.MAX_VALUE * 10; i++) {
            r.addLong(i);
        }

        System.out.println(getProcessID());
        Thread.sleep(10000000L);
    }

    public static final int getProcessID() {
        RuntimeMXBean runtimeMXBean = ManagementFactory.getRuntimeMXBean();
        System.out.println(runtimeMXBean.getName());
        return Integer.valueOf(runtimeMXBean.getName().split("@")[0]).intValue();
    }
}
